package com.example.demo_flow

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow

/**
 * @author yaotianxue
 * @description
 * @date 2025/1/9
 */
class MainViewModel: ViewModel() {
    //流
    var time = flow {
        var num = 0
        while (true){
            emit(num)
            delay(1000)
            num ++
        }
    }
    var time2 = flow {
        var num = 300
        while (true){
            emit(num)
            delay(2000)
            num ++
        }
    }
}